<template>
  <div class="">
    <div class="page-filter mb10 fl">
      <el-form ref="filter" :model="filter" label-width="0">
        <el-form-item class="mr10 mb5 fl">
          <el-input v-model="filter.name" placeholder="供应商名称" size="small" clearable />
        </el-form-item>
        <el-form-item class="mr10 mb5 fl" style="width: 300px">
          <el-button size="small" @click="app.resetFields($refs['filter'].$parent,'filter')">清 空</el-button>
          <el-button type="primary" size="small" @click="getList">查 询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table v-loading="app.loading" class="search-table" :data="list" border fit highlight-current-row style="width: 100%;">
      <el-table-column label="序号" align="center" width="56px">
        <template slot-scope="{$index}">
          {{ $index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="供应商名称" width="260px" prop="name" />
      <el-table-column label="统一信用代码" width="170px" prop="credit_code" />
      <el-table-column label="注册资本/万元" align="right" width="120px" prop="registered_capital" />
      <el-table-column label="主营业务" min-width="340px" prop="main_business">
        <template slot-scope="{row}">
          <span v-if="row.main_business">{{ row.main_business }}<br/></span>
          <span v-if="row.remark">{{ row.remark }}<br/></span>
        </template>
      </el-table-column>
      <el-table-column label="付款方式" width="90px" prop="payment_type" />
      <el-table-column label="结算周期" width="90px" prop="settlement_period" />
      <el-table-column label="联系人" width="140px" prop="contacts" />
      <el-table-column label="电话" align="right" width="140px" prop="phone" />
      <el-table-column label="地址" width="140px" prop="addr" />
      <el-table-column label="开户行" width="140px" prop="bank" />
      <el-table-column label="账号" width="140px" prop="account" />
      <el-table-column label="邮箱" width="140px" prop="mailbox" />
      <el-table-column label="等级" align="center" width="80px" prop="rate" />
      <el-table-column label="申请人" width="120px" prop="nickname" />
      <el-table-column label="申请时间" align="center" width="145px" prop="apply_time" />
      <el-table-column label="操作" align="center" width="90px" fixed="right">
        <template slot-scope="{row}">
          <el-dropdown>
            <el-button type="primary" size="mini">
              操作<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                @click.native="handleDialog({...row, ...
                {dTitle: '编辑供应商', dType: 'edit', dField: dField}})"
              >
                编 辑
              </el-dropdown-item>
              <el-dropdown-item
                @click.native="files({e_id: row.id, type: '',
                                      db_type: 'logc_supplier_archives'})"
              >
                附 件
              </el-dropdown-item>
              <el-dropdown-item @click.native="handleDelete(row)">删 除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="filter.pageAll>0" :total="filter.pageAll" :page.sync="filter.pageCurrent" :limit.sync="filter.pageNumber" @pagination="getList" />
    <Cos ref="cos" :info="dialog" />
    <Dialog ref="dialog" :get-data="getList" :info="dialog" />
  </div>
</template>

<script>
import { suppliers, delSup } from '@/api/supplier'
import Dialog from './components/supplier-dialog'
import page from '@/utils/page'

export default {
  name: '',
  components: { Dialog },
  extends: page,
  props: {
    reqList: {
      default: suppliers,
      type: Function
    },
    reqDel: {
      default: delSup,
      type: Function
    }
  },
  data() {
    return {
      dField: ['id', 'contacts', 'phone', 'addr', 'bank', 'account', 'mailbox', 'name', 'registered_capital', 
      'credit_code', 'main_business', 'settlement_period', 'payment', 'rate', 'remark']
    }
  },
  created() {
    this.getList()
  },
  methods: {
  }
}
</script>
